How to calculate age using query builder in laravel

78

You can use selectRaw and then use mysql function like this

$user_info = DB::table('users')
                ->selectRaw("TIMESTAMPDIFF(YEAR, DATE(dob), current_date) AS age")
                ->get();

Comments

Submit
0 Comments